package com.group3.controller.studentController;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.group3.domain.PunchRecord;
import com.group3.pojo.Page;
import com.group3.service.StudentPunchRecordService;
import com.group3.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * StudentPunchRecordController
 *
 * @author HY
 * 2021/06/05 16:26
 **/

@Api(tags = "学生接口")
@RestController
@RequestMapping("/student/punch")
@CrossOrigin
public class StudentPunchRecordController {

    @Resource
    private StudentPunchRecordService studentPunchRecordService;

    @GetMapping(value = "/punchRecord")
    @ApiOperation(value = "根据学生id查询学生个人打卡记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "打卡日期(前)", dataType = "Date"),
            @ApiImplicitParam(name = "endTime", value = "打卡日期(后)", dataType = "Date"),
            @ApiImplicitParam(name = "studentId", value = "学生id",required = true, dataType = "String"),
            @ApiImplicitParam(name = "pageNumber", value = "页码",required = true, dataType = "String"),
            @ApiImplicitParam(name = "pageSize", value = "每页大小",required = true, dataType = "String"),
    })
    public Result<List<PunchRecord>> getPunchRecord(
            String studentId,
            @DateTimeFormat(pattern="yyyy-MM-dd")
                    Date startTime,
            @DateTimeFormat(pattern="yyyy-MM-dd")
                    Date endTime, Page page){

        Result result = studentPunchRecordService.getPunchRecord(studentId,startTime,endTime,page);

        return result;
    };
}
